#!/bin/bash

source utils.sh

read -p "输入邮箱地址: " i_email
read -p "是否使用阿里云软件源? [Y/n]" i_source
read -p "是否安装 Zsh? [Y/n]" i_zsh
read -p "是否安装增强工具? [Y/n]" i_plus

# 更换 sources.list
if [ "$i_source" != "n" ]; then
	sudo mv /etc/apt/sources.list /etc/apt/sources.list.old
	sudo wget https://gitee.com/xuender/ubuntu/raw/master/etc/apt/sources.list \
		-O /etc/apt/sources.list
	# 更新软件
	sudo apt update
	sudo apt upgrade -y
fi

# 版本控制
sudo apt install -y git
# git 配置
if cover ~/.gitconfig; then
	ln -s ~/.dotfiles/.gitconfig ~/.gitconfig
fi
# git 通用忽略
if cover ~/.gitignore; then
	ln -s ~/.dotfiles/.gitignore ~/.gitignore
fi

# 设置git用户
git config --global user.name $USER
git config --global user.email $i_email

# 远程访问
sudo apt install -y ssh
# 下载工具
sudo apt install -y \
	wget \
	curl

# 监测工具
if [ "$i_plus" != "n" ]; then
	# 磁盘占用检查
	sudo apt install -y ncdu
	# 更漂亮的top
	sudo apt install -y htop
	# 翻译工具
	sudo apt install -y translate-shell
	# 网络工具
	sudo apt install -y net-tools
fi

# zsh
if [ "$i_zsh" != "n" ]; then
	# shell
	sudo apt install -y zsh
	# 语法高亮
	sudo apt install -y zsh-syntax-highlighting
	# oh my zsh
	if cover ~/.oh-my-zsh; then
		sh -c "$(wget -O- https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
	fi
	# powerlevel9k
	if cover ~/.oh-my-zsh/custom/themes/powerlevel9k; then
		git clone --depth=1 https://github.com/Powerlevel9k/powerlevel9k.git \
			~/.oh-my-zsh/custom/themes/powerlevel9k
	fi
	# 配置文件
	if cover ~/.zshrc; then
		ln -s ~/.dotfiles/.zshrc ~/.zshrc
	fi
	# 目录跳转
	sudo apt install -y autojump
fi

# 解压工具
sudo apt install -y unar
# 生成目录结构
sudo apt install -y tree
# 压缩工具
sudo apt install -y p7zip-full
